<template>
  <div>
    <ranking-item v-on:childByFeedList="childByFeedList"></ranking-item>
    <div class="rankinglist" v-loading="loading">
      <div
        class="rankinglist-item"
        v-for="(item, index) in rankingLis"
        :key="index"
      >
        <div class="ranking-img">
          <div v-if="index == 0">
            <img src="../../assets/img/one.svg" alt="" />
          </div>
          <div v-if="index == 1">
            <img src="../../assets/img/tow.svg" alt="" />
          </div>
          <div v-if="index == 2">
            <img src="../../assets/img/disan.svg" alt="" />
          </div>
          <div v-if="index != 0 && index != 1 && index != 2">
            <div class="ranking-bottom">
              {{ index + 1 }}
            </div>
          </div>
        </div>

        <div class="ranking-foodimg">
          <div class="imgChuLi">
            <a :href="footHref + rankingLis[index].fid"
              ><img :src="rankingLis[index].fimg" alt=""
            /></a>
          </div>
        </div>

        <div class="ranking-jies">
          <div class="jiesName">
            <a :href="footHref + rankingLis[index].fid">{{
              rankingLis[index].fname
            }}</a>
          </div>
          <div class="jiesLie">
            <a :href="footHref + rankingLis[index].fid"
              >美食类别 : {{ rankingLis[index].ftName }}</a
            >
          </div>
          <div class="jiesNei">
            <a :href="footHref + rankingLis[index].fid">{{
              rankingLis[index].fcontent
            }}</a>
          </div>
          <div class="jiesCount">
            <a :href="footHref + rankingLis[index].fid"
              >访问数 : {{ rankingLis[index].fvisits }}
            </a>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { request } from "../../network/request";
import RankingItem from "../rankingitem/RankingItem.vue";
export default {
  components: { RankingItem },
  name: "RankingList",
  data() {
    return {
      rankingLis: "",
      footHref: "/showfood?fid=",
      loading: true,
    };
  },
  created() {
    request({
      url: "/foot/queryRankingFoots",
      method: "get",
    })
      .then((res) => {
        this.rankingLis = res.data.data;
        this.loading = false;
        console.log(res.data.data);
      })
      .catch((err) => {
        console.log(err);
      });
  },
  methods: {
    childByFeedList: function (childValue) {
      this.rankingLis = childValue;
    },
  },
};
</script>

<style>
.rankinglist {
  margin-top: 1.2rem;
  margin-left: 2.4rem;
}

.ranking-jies {
  margin-left: 0.15rem;
  width: 5rem;
}

.ranking-jies a {
  text-decoration: none;
}

.ranking-foodimg {
  width: 2.5rem;
  height: 1.5rem;
  margin-bottom: 0.3rem;
}

.imgChuLi {
  width: 2.3rem;
  height: 1.5rem;
  border-radius: 0.08rem;
  overflow: hidden;
}

.ranking-foodimg img {
  width: 2.3rem;
  height: 1.5rem;
  border-radius: 0.08rem;
  transition: all 0.5s;
}

.ranking-bottom {
  width: 0.3rem;
  height: 0.3rem;
  margin-right: 0.3rem;
  margin-left: 0.2rem;
  background-color: rgb(125, 214, 250);
  border-radius: 50%;
  text-align: center;
  line-height: 0.3rem;
  color: #fff;
  font-size: 0.12rem;
}

.ranking-foodimg img:hover {
  transform: scale(1.2);
}

.rankinglist-item {
  width: 85%;
  display: flex;
  border-bottom: 1px solid rgb(229, 229, 229);
  margin-top: 0.3rem;
}

.ranking-img {
  font-size: 0.1rem;
}

.ranking-img img {
  width: 0.3rem;
  height: 0.3rem;
  margin-right: 0.25rem;
  margin-left: 0.15rem;
}

.jiesName,
.jiesLie,
.jiesNei,
.jiesCount {
  font-size: 0.1rem;
}

.jiesName a {
  font-size: 0.15rem;
  color: rgb(19, 18, 18);
}

.jiesLie {
  margin-top: 0.1rem;
}

.jiesNei {
  margin-top: 0.2rem;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}

.jiesNei a,
.jiesCount a {
  color: rgb(19, 18, 18);
}

.jiesLie a {
  color: rgb(126, 120, 120);
}

.jiesCount {
  margin-top: 0.4rem;
}
</style>